<?php // Eugenio Ghiglia <eugenio@blux.org>
include("../settings.php");

echo '<html>
<head>
  <title>Rapporto ADV</title>
  <style>
  body {
  font-family: arial;
  }
  </style>
</head>
<body>';

// Accesso al database
require_once("../lib/class.db.php");

$db = new Db();
$db->type=$db_type;
if (!$db->connetti($_db_host, $_db_user, $_db_psw, $_db_name)) {
    die('<div>Errore nella connessione al DB!</div>');
}


$codice=trim($_GET['c']);

$sql="SELECT * FROM tbl_banner WHERE id='".addslashes($codice)."'";
$db->sql_arr($sql, $banner, $n_banner);

if ($n_banner) {

echo '
<div style="padding:5px;border:1px solid #000000;background-color:#80FFC0;">
   <table cellpadding="5" cellspacing="0" border="0">
      <tr>
         <td style="font-weight:bold;">Advertiser</td>
         <td style="color:#0000FF;font-weight:bold;">'.$banner[0]['advertiser'].'</td>
      </tr>
      <tr>
         <td style="font-weight:bold;">Target</td>
         <td style="color:#0000FF;font-weight:bold;"><a href="'.$banner[0]['target'].'">'.$banner[0]['target'].'</a></td>
      </tr>
      <tr>
         <td style="font-weight:bold;">CPC</td>
         <td style="color:#0000FF;font-weight:bold;">'.$banner[0]['cpc'].'</td>
      </tr>
      <tr>
         <td style="font-weight:bold;">Total Clic</td>
         <td style="color:#0000FF;font-weight:bold;">'.$banner[0]['clic_counter'].'</td>
      </tr>
      <tr>
         <td style="font-weight:bold;">Limit Date</td>
         <td style="color:#0000FF;font-weight:bold;">'.$banner[0]['limit_date'].'</td>
      </tr>
      <tr>
         <td style="font-weight:bold;">Limit Clic</td>
         <td style="color:#0000FF;font-weight:bold;">'.$banner[0]['limit_clic'].'</td>
      </tr>
      <tr>
         <td style="font-weight:bold;">Insert Date</td>
         <td style="color:#0000FF;font-weight:bold;">'.$banner[0]['data_inserimento'].'</td>
      </tr>
   </table>
</div>
<br/>
';

// log clic
$sql="SELECT * FROM tbl_banner_log WHERE banner='".$banner[0]['banner']."' ORDER by timelog";
$db->sql_arr($sql, $record, $n);
if ($n) {
  echo '<div>
        <table cellpadding="3" cellspacing="0" border="1" style="font-size:12px;">
        <tr>
           <th style="background-color:#FFFF80;text-align:left">date time</th>
           <th style="background-color:#FFFF80;text-align:left">ip</th>
           <th style="background-color:#FFFF80;text-align:left">referer</th>
           <th style="background-color:#FFFF80;text-align:left">agent</th>
        </tr>';

  for ($i=0;$i<$n;$i++) {
    echo '
       <tr>
         <td>'.$record[$i]['timelog'].'&nbsp;</td>
         <td>'.$record[$i]['ip'].'&nbsp;</td>
         <td>'.$record[$i]['referer'].'&nbsp;</td>
         <td>'.$record[$i]['agent'].'&nbsp;</td>
      </tr>';
  }

  echo '</table></div>';
}


}

$db->disconnetti();
echo '</body></html>';
?>
